package org.nepu.scr.indexrate.converter.drillingrate.emergencycapability;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.emergencycapability.PreventionInput;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class PreventionInputConverter implements AttributeConverter<PreventionInput, String> {
    @Override
    public String convertToDatabaseColumn(PreventionInput preventionInput) {
        return JSONUtil.toJsonStr(preventionInput);
    }

    @Override
    public PreventionInput convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, PreventionInput.class);
    }
}
